package com.googlecode.recycled.spring;

import com.googlecode.recycled.lang.assertions.Assert;
import org.apache.commons.lang.UnhandledException;
import org.jibx.runtime.JiBXException;
import org.springframework.oxm.jibx.JibxMarshaller;

public class JibxMarshallers {

    protected JibxMarshallers() {
    }

    public static JibxMarshaller newJibxMarshaller(Class type) {
        Assert.notNull(type);

        JibxMarshaller jibxMarshaller = new JibxMarshaller();
        jibxMarshaller.setTargetClass(type);
        try {
            jibxMarshaller.afterPropertiesSet();
        } catch (JiBXException e) {
            throw new UnhandledException(e);
        }
        return jibxMarshaller;
    }

}
